<?xml version='1.0' encoding='UTF-8' ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui">

    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Facelets Template</title>
    </h:head>
    <ui:insert name="content">
        <div class="row" >
            <div class="col-lg-12">
                <div class="panel panel-primary">
                    <h:messages id="msg" globalOnly="true" styleClass="list-group" infoClass="list-group-item list-group-item-success"
                                errorClass="list-group-item list-group-item-danger" />
                    <div class="panel-heading" style="font-weight: bold;">Asignacion de Can</div>
                    <div class="panel-body">
                        <div class="row" id="modificarComercio">
                            <div class="col-lg-8 col-lg-offset-1">
                                <h:form id="frmRegistrarUser" styleClass="form-horizontal" >                                    
                                    <div class="form-group has-feedback"> 
                                        <label for="rol" class="col-sm-5 control-label" style="text-align: right;">Monto :</label>
                                        <div class="col-sm-5">
                                            <p:inputText styleClass="form-control" id="monto" value="#{admin.recarga.monto}" maxlength="60"/>
                                        </div>	
                                    </div>
                                    <br />
                                    <p:commandButton value="Guardar" actionListener="#{admin.insertarRecarga}" styleClass="btn btn-primary" update=":tab:msg, :tab:frmRegistrarUser:monto"/>                                     
                                </h:form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <h:form id="form1">
            <p:tabView id="tabView">
                <p:tab id="tab1" title="Recargas Sin Usar">

                    <p:dataTable id="datatable" var="cdr" 
                                 emptyMessage="No se han registrados codigos" value="#{admin.lstSinUsar}"
                                 paginator="true" rows="10"  paginatorPosition="bottom" rowIndexVar="rowIndex"
                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                 rowsPerPageTemplate="5,10,15">
                        <p:column headerText="#" style="text-align: center;">
                            <h:outputText value="#{rowIndex+1}" />
                        </p:column>                
                        <p:column headerText="Fecha" >  
                            <h:outputText value="#{cdr.fechaGenerado}" >
                                <f:convertDateTime type="date" pattern="dd-MM-YY hh:mm"  timeZone="America/Lima" />
                            </h:outputText>  
                        </p:column>
                        <p:column headerText="Monto " style="text-align: right;" >  
                            <h:outputText value="#{admin.convertDouble(cdr.monto)}" />  
                        </p:column>  
                        <p:column headerText="Opciones" style="text-align: center;" >  
                            <p:commandButton icon="icon-eye" actionListener="#{admin.capturar(cdr)}" style="font-size: 12px;"
                                             oncomplete="dlgEl.show()" update=":tab:form1:dlgEl"/>
                            <p:commandButton icon="icon-delete" actionListener="#{admin.capturar(cdr)}" style="font-size: 12px;" 
                                             oncomplete="dlgX.show()"/>
                        </p:column> 
                    </p:dataTable>
                </p:tab>
                <p:tab id="tab2" title="Recargas Usados">
                    <p:dataTable id="datatable2" var="cdr" 
                                 emptyMessage="No hay codigos usados" value="#{admin.lstUsado}"
                                 paginator="true" rows="10"  paginatorPosition="bottom" rowIndexVar="rowIndex"
                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                 rowsPerPageTemplate="5,10,15">
                        <p:column headerText="#" style="text-align: center;">
                            <h:outputText value="#{rowIndex+1}" />
                        </p:column>                
                        <p:column headerText="Fecha Generado" >  
                            <h:outputText value="#{cdr.fechaGenerado}" >
                                <f:convertDateTime type="date" pattern="dd-MM-YY hh:mm"  timeZone="America/Lima" />
                            </h:outputText>  
                        </p:column>
                        <p:column headerText="Fecha Usado" >  
                            <h:outputText value="#{cdr.fechaConsumido}" >
                                <f:convertDateTime type="date" pattern="dd-MM-YY hh:mm"  timeZone="America/Lima" />
                            </h:outputText>  
                        </p:column>
                        <p:column headerText="Monto " style="text-align: right;" >  
                            <h:outputText value="#{admin.convertDouble(cdr.monto)}" />  
                        </p:column>  
                        <p:column headerText="Codigo" style="text-align: center;" >  
                            <h:outputText value="#{cdr.id}" /> 
                        </p:column> 
                        <p:column headerText="Src" style="text-align: center;" >  
                            <h:outputText value="#{cdr.src}" /> 
                        </p:column>
                    </p:dataTable> 
                </p:tab>
            </p:tabView>
            <p:dialog id="dlgEl" modal="true" maximizable="false" widgetVar="dlgEl" header="Codigo de Recarga" resizable="false">
                <p>Codigo de Recarga : #{admin.recarga_aux.id}</p>                
            </p:dialog>
            <p:dialog modal="true" maximizable="false" widgetVar="dlgX" header="Eliminar Registro">
                <p>¿Desea eliminar el Codigo?</p>
                <h:form id="frmEliminar">
                    <p:commandButton value="Aceptar" actionListener="#{admin.eliminarRecarga}" 
                                     oncomplete="dlgX.hide();" update=":tab:form1" />
                    <p:commandButton value="Cancelar" oncomplete="dlgX.hide();" />
                </h:form>
            </p:dialog>
        </h:form>
    </ui:insert>
</html>
